<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-12-13
 * Time: 上午9:28
 */

namespace common\models\db;


use common\components\tools\ArrayHelper;
use yii\behaviors\BlameableBehavior;
use yii\behaviors\TimestampBehavior;

class DocuBody extends \common\models\db\tables\DocuBody
{
    public function behaviors()
    {
        return [
            'timestamp' => [
                'class' => TimestampBehavior::class,
            ],
            'blameable' => [
                'class' => BlameableBehavior::class,
            ],
        ];
    }

    public function rules()
    {
        $a1 = parent::rules();
        foreach ($a1 as $k => $v){
            if ($v[1] == 'required'){
                if (is_array($v[0])){
                    $a1[$k][0] = array_diff($a1[$k][0], ['created_at', 'updated_at', 'created_by', 'updated_by']);
                }
            }
        }
        $rules = [
            ['body', 'string', 'max' => 4294967295],
        ];
        $rules = ArrayHelper::merge($a1, $rules);
        return $rules;
    }
}